package com.module.oa.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.module.oa.domain.Performancecriterion;
import com.module.oa.service.IPerformancecriterionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 绩效评分标准Controller
 * 
 * @author hezhengxian
 * @date 2023-09-08
 */
@RestController
@RequestMapping("/pce")
public class PerformancecriterionController extends BaseController
{
    @Autowired
    private IPerformancecriterionService performancecriterionService;

    /**
     * 查询绩效评分标准列表
     */
    @RequiresPermissions("performancecriterion:pce:list")
    @GetMapping("/list")
    public TableDataInfo list(Performancecriterion performancecriterion)
    {
        startPage();
        List<Performancecriterion> list = performancecriterionService.selectPerformancecriterionList(performancecriterion);
        return getDataTable(list);
    }

    /**
     * 导出绩效评分标准列表
     */
    @RequiresPermissions("performancecriterion:pce:export")
    @Log(title = "绩效评分标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Performancecriterion performancecriterion)
    {
        List<Performancecriterion> list = performancecriterionService.selectPerformancecriterionList(performancecriterion);
        ExcelUtil<Performancecriterion> util = new ExcelUtil<Performancecriterion>(Performancecriterion.class);
        util.exportExcel(response, list, "绩效评分标准数据");
    }

    /**
     * 获取绩效评分标准详细信息
     */
    @RequiresPermissions("performancecriterion:pce:query")
    @GetMapping(value = "/{criterionId}")
    public AjaxResult getInfo(@PathVariable("criterionId") Integer criterionId)
    {
        return success(performancecriterionService.selectPerformancecriterionByCriterionId(criterionId));
    }

    /**
     * 新增绩效评分标准
     */
    @RequiresPermissions("performancecriterion:pce:add")
    @Log(title = "绩效评分标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Performancecriterion performancecriterion)
    {
        return toAjax(performancecriterionService.insertPerformancecriterion(performancecriterion));
    }

    /**
     * 修改绩效评分标准
     */
    @RequiresPermissions("performancecriterion:pce:edit")
    @Log(title = "绩效评分标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Performancecriterion performancecriterion)
    {
        return toAjax(performancecriterionService.updatePerformancecriterion(performancecriterion));
    }

    /**
     * 删除绩效评分标准
     */
    @RequiresPermissions("performancecriterion:pce:remove")
    @Log(title = "绩效评分标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{criterionIds}")
    public AjaxResult remove(@PathVariable Integer[] criterionIds)
    {
        return toAjax(performancecriterionService.deletePerformancecriterionByCriterionIds(criterionIds));
    }
}
